package demo1;

//牛客网:爱吃素

import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int t = in.nextInt();
        while(t-- > 0) {
            long a = in.nextLong();
            long b = in.nextLong();
            long c = a*b;
            if(isPrime(c)) {
                System.out.println("YES");
            }else {
                System.out.println("NO");
            }
        }
    }
    public static boolean isPrime(long n) {
        if(n <= 2) return false;
        long t = (long) Math.sqrt(n);
        for(int i = 2; i<=t; i++) {
            if(n%i==0) {
                return false;
            }
        }
        return true;
    }
}